let fs = require("fs");
let os= require("os");

let writestream = fs.WriteStream('./input.txt','utf-8');
// let bf2 = 'hello world';
// writestream.write(Buffer.from(bf2));
// writestream.write(Buffer.from(bf2));

let startMem=os.freemem();
// console.log('运行前内存'+startMem);
let readStream = fs.createReadStream('./input.txt',{encoding:"utf-8"});
let data = '';
readStream.on('data',function(chunk) {  
    data += chunk;
    console.log(chunk);
})

// readStream.on('close', function() {
//     console.log("已关闭");
// })

readStream.on('end', function() {
    console.log("流完了");
})
let endMem=os.freemem();
// console.log('运行后内存'+endMem);

console.log('损耗内存'+(startMem-endMem)/1024/1024);
console.log("end");
